package servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dto.AdminMerchantDto;
import dto.MerchantDto;
import dto.ResponseDto;
import pojo.MerchantApplication;
import service.MerchantApplicationManager;
import service.factory.ManagerFactory;
import util.JsonUtil;

public class GetMerchantWithStatusServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private MerchantApplicationManager amanager = null;
       
    public GetMerchantWithStatusServlet() {
        super();
        amanager = ManagerFactory.getApplicationManagerInstance();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String status = request.getParameter("status");
		List<MerchantApplication> mList = new ArrayList<>();
		if(status==null){
			mList = amanager.getAll();
		}else{
			mList = amanager.getByStatus(status);
		}
		request.setAttribute("merchants", mList);
		request.setAttribute("myStatus", status);
		System.out.println(getServletContext().getAttribute("imagepath"));
		request.getRequestDispatcher("../../merchantInfo.jsp").forward(request, response);
	}

}
